package com.deram.ctin.rest.web.controller.web;

import com.deram.ctin.common.bean.Page;
import com.deram.ctin.common.bean.PageResult;
import com.deram.ctin.dependencies.rest.base.BaseController;
import com.deram.ctin.serv.business.api.*;
import com.deram.ctin.serv.business.entity.*;
import com.deram.ctin.serv.business.filter.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhangcm
 * @version 1.0, 2017/9/28
 */
@Api(tags = {"web - 企业风险事件接口"})
@RestController
@RequestMapping("/web/enter")
public class WebEnterRiskInfoController extends BaseController {

    @Autowired
    private BusinessJudgementApi businessJudgementApi;

    @Autowired
    private BusinessCourtApi businessCourtApi;

    @Autowired
    private BusinessCourtSessionApi businessCourtSessionApi;

    @Autowired
    private BusinessEnforcementApi businessEnforcementApi;

    @Autowired
    private BusinessDishonestApi businessDishonestApi;

    @Autowired
    private BusinessJudicialSaleApi businessJudicialSaleApi;

    @Autowired
    private BusinessAbnormalApi businessAbnormalApi;

    @Autowired
    private BusinessArrearsApi businessArrearsApi;

    @Autowired
    private BusinessPledgedApi businessPledgedApi;

    @Autowired
    private BusinessMortgageApi businessMortgageApi;

    @ApiOperation(value = "裁判文书分页")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, paramType = "path"),
    })
    @GetMapping("/searchJudgement/{id}")
    public PageResult<BusinessJudgement> searchJudgement(@PathVariable Long id, Page page){
        BusinessJudgementFilter enterInfoFilter = new BusinessJudgementFilter();
        enterInfoFilter.setEnterId(id);
        return businessJudgementApi.search(enterInfoFilter,page.getPageNo(),page.getPageSize());
    }

    @ApiOperation(value = "法院公告分页")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, paramType = "path"),
    })
    @GetMapping("/searchCourt/{id}")
    public PageResult<BusinessCourt> searchCourt(@PathVariable Long id, Page page){
        BusinessCourtFilter enterInfoFilter = new BusinessCourtFilter();
        enterInfoFilter.setEnterId(id);
        return businessCourtApi.search(enterInfoFilter,page.getPageNo(),page.getPageSize());
    }

    @ApiOperation(value = "开庭公告分页")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, paramType = "path"),
    })
    @GetMapping("/searchCourtSession/{id}")
    public PageResult<BusinessCourtSession> searchCourtSession(@PathVariable Long id, Page page){
        BusinessCourtSessionFilter enterInfoFilter = new BusinessCourtSessionFilter();
        enterInfoFilter.setEnterId(id);
        return businessCourtSessionApi.search(enterInfoFilter,page.getPageNo(),page.getPageSize());
    }

    @ApiOperation(value = "被执行人信息分页")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, paramType = "path"),
    })
    @GetMapping("/searchEnforcement/{id}")
    public PageResult<BusinessEnforcement> searchEnforcement(@PathVariable Long id, Page page){
        BusinessEnforcementFilter enterInfoFilter = new BusinessEnforcementFilter();
        enterInfoFilter.setEnterId(id);
        return businessEnforcementApi.search(enterInfoFilter,page.getPageNo(),page.getPageSize());
    }

    @ApiOperation(value = "失信人信息分页")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, paramType = "path"),
    })
    @GetMapping("/searchDishonest/{id}")
    public PageResult<BusinessDishonest> searchDishonest(@PathVariable Long id, Page page){
        BusinessDishonestFilter enterInfoFilter = new BusinessDishonestFilter();
        enterInfoFilter.setEnterId(id);
        return businessDishonestApi.search(enterInfoFilter,page.getPageNo(),page.getPageSize());
    }

    @ApiOperation(value = "司法拍卖分页")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, paramType = "path"),
    })
    @GetMapping("/searchJudicialSale/{id}")
    public PageResult<BusinessJudicialSale> searchJudicialSale(@PathVariable Long id, Page page){
        BusinessJudicialSaleFilter enterInfoFilter = new BusinessJudicialSaleFilter();
        enterInfoFilter.setEnterId(id);
        return businessJudicialSaleApi.search(enterInfoFilter,page.getPageNo(),page.getPageSize());
    }

    @ApiOperation(value = "经营异常分页")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, paramType = "path"),
    })
    @GetMapping("/searchAbnormal/{id}")
    public PageResult<BusinessAbnormal> searchAbnormal(@PathVariable Long id, Page page){
        BusinessAbnormalFilter enterInfoFilter = new BusinessAbnormalFilter();
        enterInfoFilter.setEnterId(id);
        return businessAbnormalApi.search(enterInfoFilter,page.getPageNo(),page.getPageSize());
    }

    @ApiOperation(value = "欠税信息分页")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, paramType = "path"),
    })
    @GetMapping("/searchArrears/{id}")
    public PageResult<BusinessArrears> searchArrears(@PathVariable Long id, Page page){
        BusinessArrearsFilter enterInfoFilter = new BusinessArrearsFilter();
        enterInfoFilter.setEnterId(id);
        return businessArrearsApi.search(enterInfoFilter,page.getPageNo(),page.getPageSize());
    }

    @ApiOperation(value = "股权出质分页")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, paramType = "path"),
    })
    @GetMapping("/searchPledged/{id}")
    public PageResult<BusinessPledged> searchPledged(@PathVariable Long id, Page page){
        BusinessPledgedFilter enterInfoFilter = new BusinessPledgedFilter();
        enterInfoFilter.setEnterId(id);
        return businessPledgedApi.search(enterInfoFilter,page.getPageNo(),page.getPageSize());
    }

    @ApiOperation(value = "动产抵押分页")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, paramType = "path"),
    })
    @GetMapping("/searchMortgage/{id}")
    public PageResult<BusinessMortgage> searchMortgage(@PathVariable Long id, Page page){
        BusinessMortgageFilter enterInfoFilter = new BusinessMortgageFilter();
        enterInfoFilter.setEnterId(id);
        return businessMortgageApi.search(enterInfoFilter,page.getPageNo(),page.getPageSize());
    }
}
